
  <template>
    <van-search v-for="o in orderInfo" v-model="value" show-action label="订单号" :placeholder="请输入您的订单号( o.orderNumber)" @search="onSearch">
    <template #action>
      <div @click="onClickButton">查询</div>
    </template>
  </van-search>
  </template>
  <script setup>
import { ref } from 'vue';
import { onMounted } from 'vue';
import { reactive } from 'vue';
import { showToast } from 'vant';
import { default as http, getImageUrl } from '@/utils/request.js';

    const value = ref('');
    const onSearch = (val) => showToast(val); 
    const orderInfo = reactive([
]);
    const getOrderInfo=function(){
     http.get("/user/order/ordernumber/").then((res) =>{
            console.log('查询订单', res.data);
            orderInfo.splice(0);//todo 需要将原有的元素清空
    res.data.data.forEach(o => {
        orderInfo.push(o);
    });
    console.log('查询订单', orderInfo);
        }).catch(()=>{
            console.log('查询失败');
        }) }
    const onClickButton = () => showToast(value.value);
    
    onMounted(() => {
 
  getOrderInfo();


});


</script>